package com.caiheng.api.util;

import cn.hutool.core.util.StrUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class OrderUtil {

    /**
     * 产生订单号
     * @return
     */
    public static String getOrderNoByTime(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        int random = (int)(Math.random()*9000+1000);
        String order_no = sdf.format(date)+random;
        return order_no;
    }

    /**
     * 产生订单号
     * @return
     */
    public static String getOrderNoByTimespan(String sysCode){
        Date date = new Date();
        String order_no = date.getTime()+"";
        if(StrUtil.isNotEmpty(sysCode)){
            order_no = sysCode + date.getTime();
        }
        return order_no;
    }


    /**
     * 产生订单号
     * @return
     */
    public static String getOrderNoByTimespan(){
        Date date = new Date();
        String order_no = "32WT" + date.getTime();
        return order_no;
    }

    /**
     * 产生订单号
     * @return
     */
    public static String getOrderNoByTimes(){
        Date date = new Date();
        String order_no = date.getTime()+"";
        return order_no;
    }
    /**
     * 产生充电订单号
     * @return
     */
    public static String getChargerOrderNoByTimespan(){
        Date date = new Date();
        String order_no = String.format("%020d",date.getTime());
        return order_no;
    }


    /**
     *  中介信息编号
     * @return
     */
    public static String getMsgNo(String sysCode){
        Date date = new Date();
        String order_no = sysCode + "50" + date.getTime();
        return order_no;
    }

    /**
     *  中介信息编号
     * @return
     */
    public static String getMsgNo(){
        Date date = new Date();
        String order_no = "50" + date.getTime();
        return order_no;
    }

    /**
     * 产生拼团 团编号
     * @return
     */
    public static String getGroupNo(){
        Date date = new Date();
        String order_no = "32WT80" + date.getTime();
        return order_no;
    }

    /**
     * 产生商家爱活动编号
     * @return
     */
    public static String getRecordNo(){
        Date date = new Date();
        String order_no = "R" + date.getTime();
        return order_no;
    }
    /**
     * 产生商家爱活动编号
     * @return
     */
    public static String getActiveNo(){
        Date date = new Date();
        String order_no = "32WT20" + date.getTime();
        return order_no;
    }

    /**
     * 产生订单关联表的编号
     * @return
     */
    public static String getPayNo(String sysCode){
        Date date = new Date();
        String pay_no = sysCode + "30" + date.getTime();
        return pay_no;
    }
    /**
     * 产生订单关联表的编号
     * @return
     */
    public static String getPayNo(){
        Date date = new Date();
        String pay_no = "32WT30" + date.getTime();
        return pay_no;
    }

    /**
     * 产生商家爱活动编号
     * @return
     */
    public static String getVerfiyNo1(Integer estateId){
        Date date = new Date();
        String order_no = estateId +"" + date.getTime();
        return order_no;
    }

    /**
     * 产生核销码
     * @return
     */
    public static String getVerfiyNo(){
        Date date = new Date();
        String order_no = String.valueOf(date.getTime() / 1000);
        return order_no;
    }
    /**
     * 产生核销码
     * @return
     */
    public static String getVerfiyNoAndRandom(){
        Date date = new Date();
        int random = (int)(Math.random()*9000+1000);
        String order_no = String.valueOf((date.getTime() + random) / 1000);
        return order_no;
    }
}
